package com.xy.biz.xd.component;

import com.xy.biz.xd.service.DocumentReleaseService;
import com.xy.lang.domain.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.DependsOn;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author zgy
 * 扫描发行时间改变状态的定时器
 */
@Component
@DependsOn("trainStatusChangeTask")
@Slf4j
public class ReleaseStatusChangeTask {

    @Autowired
    private DocumentReleaseService documentReleaseService;

    /**
     * cron表达式：Seconds Minutes Hours DayOfMonth Month DayOfWeek [Year]
     * 每天零点扫描一次，扫描发行时间改变状态
     */
    @Scheduled(cron = "0 0 0 * * ?")
    private void changeTrainStatus() {
        Result<?> result = documentReleaseService.changeStatus();
        log.info("the release status change number is :::" + result.getData());
    }
}
